package com.wisezone.workflow.dao.ibatis;

import java.util.List;

import com.wisezone.common.dao.impl.BaseDaoImpl;
import com.wisezone.workflow.bean.WfDataDictionary;
import com.wisezone.workflow.bean.search.WfDataDictionarySearch;
import com.wisezone.workflow.dao.WfDataDictionaryDao;
import com.wisezone.workflow.exception.WfDaoException;

/**
 * IBATIS 流程数据字典实现类
 * @author tss 2009-09-05
 * 
 */
public class WfDataDictionaryDaoImpl extends BaseDaoImpl implements WfDataDictionaryDao {

    public WfDataDictionaryDaoImpl() {
        super();
    }
    

	/**
     * 获得数据字典对象
     */
	public WfDataDictionary getDataDictionary(String category, String code)
			throws WfDaoException {
		
		WfDataDictionarySearch searchEntity = new WfDataDictionarySearch();
		searchEntity.setCategory(category);
		searchEntity.setCode(code);
		return this.get(searchEntity);
	}

	/**
     * 获得数据字典ID
     */
	public Long getDataDictionaryId(String category, String code)
			throws WfDaoException {
		return getDataDictionary(category, code).getId();
	}
	
	/**
	 * 获得数据字典集合
	 * @param category 数据字典类别
	 * @return
	 * @throws WfDaoException
	 */
	public List<WfDataDictionary> listByCategory(String category) throws WfDaoException{
		
		WfDataDictionarySearch searchEntity = new WfDataDictionarySearch();
		searchEntity.setCategory(category);
		searchEntity.addSqlClause("and parent_id != 0 ");
		return this.listAll(searchEntity);
	}
	
	/**
	 * 获得数据字典集合
	 * @param parentId 父ID
	 * @return
	 * @throws WfDaoException
	 */
	public List<WfDataDictionary> listByParentId(Long parentId) throws WfDaoException{
		
		WfDataDictionarySearch searchEntity = new WfDataDictionarySearch();
		searchEntity.setParentId(parentId);
		return this.listAll(searchEntity);
	}


 

   
   

   
}